package com.site.web.controller.war;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.site.common.annotation.Log;
import com.site.common.core.controller.BaseController;
import com.site.common.core.domain.AjaxResult;
import com.site.common.enums.BusinessType;
import com.site.war.domain.SiteVideo;
import com.site.war.service.ISiteVideoService;
import com.site.common.utils.poi.ExcelUtil;
import com.site.common.core.page.TableDataInfo;

/**
 * 监控视频地址Controller
 *
 * @author site
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/war/video")
public class SiteVideoController extends BaseController
{
    @Autowired
    private ISiteVideoService siteVideoService;

    /**
     * 查询监控视频地址列表
     */
    @PreAuthorize("@ss.hasPermi('site:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(SiteVideo siteVideo)
    {
        startPage();
        List<SiteVideo> list = siteVideoService.selectSiteVideoList(siteVideo);
        return getDataTable(list);
    }

    /**
     * 导出监控视频地址列表
     */
    @PreAuthorize("@ss.hasPermi('site:video:export')")
    @Log(title = "监控视频地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SiteVideo siteVideo)
    {
        List<SiteVideo> list = siteVideoService.selectSiteVideoList(siteVideo);
        ExcelUtil<SiteVideo> util = new ExcelUtil<SiteVideo>(SiteVideo.class);
        util.exportExcel(response, list, "监控视频地址数据");
    }

    /**
     * 获取监控视频地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('site:video:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(siteVideoService.selectSiteVideoById(id));
    }

    /**
     * 新增监控视频地址
     */
    @PreAuthorize("@ss.hasPermi('site:video:add')")
    @Log(title = "监控视频地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SiteVideo siteVideo)
    {
        return toAjax(siteVideoService.insertSiteVideo(siteVideo));
    }

    /**
     * 修改监控视频地址
     */
    @PreAuthorize("@ss.hasPermi('site:video:edit')")
    @Log(title = "监控视频地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SiteVideo siteVideo)
    {
        return toAjax(siteVideoService.updateSiteVideo(siteVideo));
    }

    /**
     * 删除监控视频地址
     */
    @PreAuthorize("@ss.hasPermi('site:video:remove')")
    @Log(title = "监控视频地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(siteVideoService.deleteSiteVideoByIds(ids));
    }

    /**
     * ZYJ
     * 根据塔吊序列号获取视频
     * @param towerNumber
     * @return
     */
    @GetMapping("/getVideoByTowerNumber")
    public AjaxResult getVideoByTowerNumber(String towerNumber){
        return success(siteVideoService.getVideoByTowerNumber(towerNumber));
    }
}
